﻿package com.athena.process
{
	import flash.events.*;
	import flash.utils.*;
	import flash.text.TextFormat;
	import com.adobe.serialization.json.JSON;
	import flash.net.URLRequest ;
	import flash.net.URLLoader;
	import flash.net.URLVariables ;
	import flash.net.URLRequestMethod ;
	import flash.net.URLRequestHeader ;
	import flash.display.*;
	import com.athena.vo.*;
	import com.athena.controller.*;
	import com.athena.process.*;
	import fl.containers.ScrollPane; 
	import fl.controls.ScrollPolicy; 
	import flash.net.navigateToURL;
	import flash.external.ExternalInterface;
	import gs.*;
	import gs.easing.*;
	/**
	 * ...
	 * @author ...
	 */
	public class ProcessOutTable_Frame1 
	{
		public static var scrollHistoryTF_mc:MovieClip;
		public static var scrHistoryTF:ScrollPane = new ScrollPane(); 
		
		public static var TitleCaoThu : String = "" ;
		public static var tabShow : String = "";
		public static var changeGame : int = 0 ;
		public static var isChangeGame : Boolean = true ;
		public static var TimerChangeGame:Timer = new Timer(1500);
		/**********************************************************************************************/
		/***************************************Frame 1************************************************/
		/**********************************************************************************************/
		public static function GotoBacay(evt : MouseEvent) {
			ExternalInterface.call("newwindow(4)");		
			//var url:String = "http://test.athena.vn/bacay/Game.aspx?" + Cocaro.user.SessionId ; // + "&sign_user=" + ASXito.user.UserId + "&username=" + ASXito.user.Username;
            //var request:URLRequest = new URLRequest(url);
			//navigateToURL(request, "");
		}
		public static function GotoChan(evt : MouseEvent) {
			ExternalInterface.call("newwindow(2)");		
			//var url:String = "http://test.athena.vn/chan/Game.aspx?" + Cocaro.user.SessionId ; // + "&sign_user=" + ASXito.user.UserId + "&username=" + ASXito.user.Username;
            //var request:URLRequest = new URLRequest(url);
			//navigateToURL(request, "");
		}
		public static function GotoTala(evt : MouseEvent) {
			ExternalInterface.call("newwindow(1)");	
			//var url:String = "http://test.athena.vn/tala/Game.aspx?" + Cocaro.user.SessionId ; // + "&sign_user=" + ASXito.user.UserId + "&username=" + ASXito.user.Username;
            //var request:URLRequest = new URLRequest(url);
			//navigateToURL(request, "");
		}
		public static function GotoBinh(evt : MouseEvent) {
			ExternalInterface.call("newwindow(8)");	
			//var url:String = "http://test.athena.vn/binh/Game.aspx?" + Cocaro.user.SessionId ; // + "&sign_user=" + ASXito.user.UserId + "&username=" + ASXito.user.Username;
            //var request:URLRequest = new URLRequest(url);
			//navigateToURL(request, "");
		}
		public static function GotoTienlen(evt : MouseEvent) {
			ExternalInterface.call("newwindow(5)");		
			//var url:String = "http://test.athena.vn/tienlenmn/Game.aspx?" + Cocaro.user.SessionId ; // + "&sign_user=" + ASXito.user.UserId + "&username=" + ASXito.user.Username;
            //var request:URLRequest = new URLRequest(url);
			//navigateToURL(request, "");
		}
		public static function GotoXito(evt : MouseEvent) {
			ExternalInterface.call("newwindow(4)");		
			//var url:String = "http://test.athena.vn/poker/Game.aspx?" + Cocaro.user.SessionId ; //+ "&sign_user=" + Cocaro.user.UserId + "&username=" + Cocaro.user.Username;
            //var request:URLRequest = new URLRequest(url);
			//navigateToURL(request, "");
		}
		public static function StartTimerChangeGame(evt:TimerEvent) : void { //Dem thoi gian an ==> Tu dong click player
			if (TimerChangeGame.currentCount == TimerChangeGame.repeatCount) {
				isChangeGame = true ;
				TimerChangeGame.stop() ;
			}
		}
		public static function InitChangeGame() : void {
			Cocaro.mainStage_mc.ChangeGame_mc.Binh_btn.addEventListener(MouseEvent.CLICK, GotoBinh) ;
			Cocaro.mainStage_mc.ChangeGame_mc.Chan_btn.addEventListener(MouseEvent.CLICK, GotoChan) ;
			Cocaro.mainStage_mc.ChangeGame_mc.Tala_btn.addEventListener(MouseEvent.CLICK, GotoTala) ;
			Cocaro.mainStage_mc.ChangeGame_mc.Xito_btn.addEventListener(MouseEvent.CLICK, GotoXito) ;
			Cocaro.mainStage_mc.ChangeGame_mc.Bacay_btn.addEventListener(MouseEvent.CLICK, GotoBacay) ;
			Cocaro.mainStage_mc.ChangeGame_mc.Tienlen_btn.addEventListener(MouseEvent.CLICK, GotoTienlen) ;	
			Cocaro.mainStage_mc.ChangeGame_mc.Up_btn.addEventListener(MouseEvent.CLICK, UpChangeGame) ;			
			Cocaro.mainStage_mc.ChangeGame_mc.Down_btn.addEventListener(MouseEvent.CLICK, DownChangeGame) ;
			Cocaro.mainStage_mc.ChangeGame_mc.Down_btn.gotoAndStop(2) ;
			changeGame = 2 ;
		}
		public static function UpChangeGame(evt : MouseEvent) {
			if (changeGame == 0) {
				Cocaro.mainStage_mc.ChangeGame_mc.Up_btn.gotoAndStop(2) ;
				return ;
			}
			if (!isChangeGame) return ;
			Cocaro.mainStage_mc.ChangeGame_mc.Down_btn.gotoAndStop(1) ;
			isChangeGame = false ;
			changeGame-- ;
			if (TimerChangeGame.running) TimerChangeGame.stop() ;
			TimerChangeGame = new Timer(500) ;
			TimerChangeGame.repeatCount = 1 ;
			TimerChangeGame.addEventListener(TimerEvent.TIMER, StartTimerChangeGame);				
			TimerChangeGame.start() ;
			if (Cocaro.mainStage_mc.ChangeGame_mc.Binh_btn.y > 40) {
				Cocaro.mainStage_mc.ChangeGame_mc.Binh_btn.visible = true ;
				moveObj(Cocaro.mainStage_mc.ChangeGame_mc.Binh_btn, Cocaro.mainStage_mc.ChangeGame_mc.Binh_btn.x, Cocaro.mainStage_mc.ChangeGame_mc.Binh_btn.y - 50) ;
			} else {
				Cocaro.mainStage_mc.ChangeGame_mc.Binh_btn.y = Cocaro.mainStage_mc.ChangeGame_mc.Binh_btn.y - 50 ;
				Cocaro.mainStage_mc.ChangeGame_mc.Binh_btn.visible = false ;
			}
			if (Cocaro.mainStage_mc.ChangeGame_mc.Chan_btn.y > 40) {
				Cocaro.mainStage_mc.ChangeGame_mc.Chan_btn.visible = true ;
				moveObj(Cocaro.mainStage_mc.ChangeGame_mc.Chan_btn, Cocaro.mainStage_mc.ChangeGame_mc.Chan_btn.x, Cocaro.mainStage_mc.ChangeGame_mc.Chan_btn.y - 50) ;
			} else { 
				Cocaro.mainStage_mc.ChangeGame_mc.Chan_btn.visible = false ;
				Cocaro.mainStage_mc.ChangeGame_mc.Chan_btn.y = Cocaro.mainStage_mc.ChangeGame_mc.Chan_btn.y - 50 ;
			}
			Cocaro.mainStage_mc.ChangeGame_mc.Tala_btn.visible = true ;
			moveObj(Cocaro.mainStage_mc.ChangeGame_mc.Tala_btn, Cocaro.mainStage_mc.ChangeGame_mc.Tala_btn.x, Cocaro.mainStage_mc.ChangeGame_mc.Tala_btn.y - 50) ;
			Cocaro.mainStage_mc.ChangeGame_mc.Xito_btn.visible = true ;
			moveObj(Cocaro.mainStage_mc.ChangeGame_mc.Xito_btn, Cocaro.mainStage_mc.ChangeGame_mc.Xito_btn.x, Cocaro.mainStage_mc.ChangeGame_mc.Xito_btn.y - 50) ;
			if (Cocaro.mainStage_mc.ChangeGame_mc.Tienlen_btn.y < 280) {
				Cocaro.mainStage_mc.ChangeGame_mc.Tienlen_btn.visible = true ;
				moveObj(Cocaro.mainStage_mc.ChangeGame_mc.Tienlen_btn, Cocaro.mainStage_mc.ChangeGame_mc.Tienlen_btn.x, Cocaro.mainStage_mc.ChangeGame_mc.Tienlen_btn.y - 50) ;
			} else { 
				Cocaro.mainStage_mc.ChangeGame_mc.Tienlen_btn.visible = false ;
				Cocaro.mainStage_mc.ChangeGame_mc.Tienlen_btn.y = Cocaro.mainStage_mc.ChangeGame_mc.Tienlen_btn.y - 50 ;
			}
			if (Cocaro.mainStage_mc.ChangeGame_mc.Bacay_btn.y < 280) {
				Cocaro.mainStage_mc.ChangeGame_mc.Bacay_btn.visible = true ;
				moveObj(Cocaro.mainStage_mc.ChangeGame_mc.Bacay_btn, Cocaro.mainStage_mc.ChangeGame_mc.Bacay_btn.x, Cocaro.mainStage_mc.ChangeGame_mc.Bacay_btn.y - 50) ;
			} else { 
				Cocaro.mainStage_mc.ChangeGame_mc.Bacay_btn.visible = false ;
				Cocaro.mainStage_mc.ChangeGame_mc.Bacay_btn.y = Cocaro.mainStage_mc.ChangeGame_mc.Bacay_btn.y - 50 ;
			}
		}
		public static function DownChangeGame(evt : MouseEvent) {
			if (changeGame == 2) {
				Cocaro.mainStage_mc.ChangeGame_mc.Down_btn.gotoAndStop(2) ;
				return ;
			}
			if (!isChangeGame) return ;
			Cocaro.mainStage_mc.ChangeGame_mc.Up_btn.gotoAndStop(1) ;
			isChangeGame = false ;
			changeGame++ ;	
			if (TimerChangeGame.running) TimerChangeGame.stop() ;
			TimerChangeGame = new Timer(500) ;
			TimerChangeGame.repeatCount = 1 ;
			TimerChangeGame.addEventListener(TimerEvent.TIMER, StartTimerChangeGame);				
			TimerChangeGame.start() ;
			if (Cocaro.mainStage_mc.ChangeGame_mc.Binh_btn.y > -10) {
				Cocaro.mainStage_mc.ChangeGame_mc.Binh_btn.visible = true ;
				moveObj(Cocaro.mainStage_mc.ChangeGame_mc.Binh_btn, Cocaro.mainStage_mc.ChangeGame_mc.Binh_btn.x, Cocaro.mainStage_mc.ChangeGame_mc.Binh_btn.y + 50) ;
			} else {
				Cocaro.mainStage_mc.ChangeGame_mc.Binh_btn.visible = false ;
				Cocaro.mainStage_mc.ChangeGame_mc.Binh_btn.y = Cocaro.mainStage_mc.ChangeGame_mc.Binh_btn.y + 50 ;
			}
			if (Cocaro.mainStage_mc.ChangeGame_mc.Chan_btn.y > -10) {
				Cocaro.mainStage_mc.ChangeGame_mc.Chan_btn.visible = true ;
				moveObj(Cocaro.mainStage_mc.ChangeGame_mc.Chan_btn, Cocaro.mainStage_mc.ChangeGame_mc.Chan_btn.x, Cocaro.mainStage_mc.ChangeGame_mc.Chan_btn.y + 50) ;
			} else {
				Cocaro.mainStage_mc.ChangeGame_mc.Chan_btn.visible = false ;
				Cocaro.mainStage_mc.ChangeGame_mc.Chan_btn.y = Cocaro.mainStage_mc.ChangeGame_mc.Chan_btn.y + 50 ;
			}
			Cocaro.mainStage_mc.ChangeGame_mc.Tala_btn.visible = true ;
			moveObj(Cocaro.mainStage_mc.ChangeGame_mc.Tala_btn, Cocaro.mainStage_mc.ChangeGame_mc.Tala_btn.x, Cocaro.mainStage_mc.ChangeGame_mc.Tala_btn.y + 50) ;
			Cocaro.mainStage_mc.ChangeGame_mc.Xito_btn.visible = true ;
			moveObj(Cocaro.mainStage_mc.ChangeGame_mc.Xito_btn, Cocaro.mainStage_mc.ChangeGame_mc.Xito_btn.x, Cocaro.mainStage_mc.ChangeGame_mc.Xito_btn.y + 50) ;
			if (Cocaro.mainStage_mc.ChangeGame_mc.Tienlen_btn.y < 240) {
				Cocaro.mainStage_mc.ChangeGame_mc.Tienlen_btn.visible = true ;
				moveObj(Cocaro.mainStage_mc.ChangeGame_mc.Tienlen_btn, Cocaro.mainStage_mc.ChangeGame_mc.Tienlen_btn.x, Cocaro.mainStage_mc.ChangeGame_mc.Tienlen_btn.y + 50) ;
			} else  {
				Cocaro.mainStage_mc.ChangeGame_mc.Tienlen_btn.visible = false ;
				Cocaro.mainStage_mc.ChangeGame_mc.Tienlen_btn.y = Cocaro.mainStage_mc.ChangeGame_mc.Xito_btn.y + 50 ;
			}
			if (Cocaro.mainStage_mc.ChangeGame_mc.Bacay_btn.y < 240) {
				Cocaro.mainStage_mc.ChangeGame_mc.Bacay_btn.visible = true ;
				moveObj(Cocaro.mainStage_mc.ChangeGame_mc.Bacay_btn, Cocaro.mainStage_mc.ChangeGame_mc.Bacay_btn.x, Cocaro.mainStage_mc.ChangeGame_mc.Bacay_btn.y + 50) ;
			} else {
				Cocaro.mainStage_mc.ChangeGame_mc.Bacay_btn.visible = false ;
				Cocaro.mainStage_mc.ChangeGame_mc.Bacay_btn.y = Cocaro.mainStage_mc.ChangeGame_mc.Bacay_btn.y + 50 ;
			}
		}
		public static function moveObj(_mc: MovieClip, xNew:Number, yNew:Number)	{				
			TweenMax.to(_mc, 0.2, { x:xNew, y:yNew, ease:Expo.easeOut, onComplete:Latbai() } );
			function Latbai()
			{
				
			}
		}
		public static function initLevelRoom(str:String):void {
			//Cocaro.tf.appendText("=>InitLevel:" + str) ;
			Cocaro.InitMoney = 0;
			Cocaro.PlayMoney = 0;
			Cocaro.NonPlayMoney = 0;
			var object :Array  = (JSON.decode(str) as Array) ;		
			Cocaro.mainStage_mc.gotoAndStop(3);
			Cocaro.mainStage_mc.BG_mc.addChild(Cocaro.christmas_Loader) ;
			Cocaro.mainStage_mc.btnLQAG.gotoAndStop(2) ;
			Cocaro.mainStage_mc.btnNew.gotoAndStop(1) ;
			Cocaro.mainStage_mc.btnDG.gotoAndStop(1) ;
			Cocaro.mainStage_mc.btnCT.gotoAndStop(1) ;
			Cocaro.mainStage_mc.New_mc.visible = false;
			Cocaro.mainStage_mc.CT_mc.visible = false ;
			Cocaro.mainStage_mc.DG_mc.visible = false ;
			Cocaro.mainStage_mc.LQAG_mc.visible = true ;
			//{Hien thi thong tin nguoi choi
			if ((Cocaro.currPlayer.TinyURL != "") && (Cocaro.currPlayer.TinyURL != null)) {
				var imageLoader:Loader = new Loader();
				var image:URLRequest = new URLRequest(Cocaro.currPlayer.TinyURL) ;
				imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoader);				
				imageLoader.name = "BigAW" ;
				imageLoader.load(image);				
				function onLoader(evt:Event)
				{
					imageLoader.width = 50 ;
					imageLoader.height = 50 ;
					if (Cocaro.mainStage_mc.Profile_mc.Avatar_mc.numChildren > 1)
						Cocaro.mainStage_mc.Profile_mc.Avatar_mc.removeChildAt(1) ;
					Cocaro.mainStage_mc.Profile_mc.Avatar_mc.addChild(imageLoader);
				}				
			}
			Cocaro.mainStage_mc.Profile_mc.Name_txt.text = Cocaro.currPlayer.PlayerName ;
			Cocaro.mainStage_mc.Profile_mc.Mark_txt.text = BasicFunction.numberFormat(Cocaro.currPlayer.Mark, 0, false, true) + " AG";		
			Cocaro.mainStage_mc.Profile_mc.MarkLQ_txt.text = BasicFunction.numberFormat(Cocaro.currPlayer.MarkLQ, 0, false, true) + " LQ";	
			
			Cocaro.InitMoney =  Cocaro.currPlayer.Mark;
			//Cocaro.tf.appendText("==>" + Cocaro.currPlayer.VIP + "-" + Cocaro.currPlayer.Mark) ;
			Cocaro.mainStage_mc.Profile_mc.Vip_mc.visible = true ;
			Cocaro.mainStage_mc.Profile_mc.Vip_mc.gotoAndStop(Cocaro.currPlayer.VIP + 1) ;
			var positionKhung : int = 1 ;			
			if (Cocaro.currPlayer.Mark > Cocaro.vip) {
				positionKhung = 3 ;
				Cocaro.formatAvatar_Name.color = 0xFFFFFF ;
			} else {
				if (Cocaro.currPlayer.Mark > Cocaro.vipSilver)
					positionKhung = 2 ;
				Cocaro.formatAvatar_Name.color = 0xE5DFE9 ;
			}
			Cocaro.mainStage_mc.Profile_mc.Name_txt.setTextFormat(Cocaro.formatAvatar_Name) ;
			Cocaro.mainStage_mc.Profile_mc.Mark_txt.setTextFormat(Cocaro.formatAvatar_Mark) ;	
			Cocaro.mainStage_mc.Profile_mc.MarkLQ_txt.setTextFormat(Cocaro.formatAvatar_MarkLQ) ;
			Cocaro.mainStage_mc.Profile_mc.BG_Avatar.gotoAndStop(positionKhung) ;
			//}
			//{Controller Button
			//Cocaro.tf.appendText("==>1") ;
			Cocaro.mainStage_mc.Error_btn.addEventListener(MouseEvent.CLICK, Error_Click) ;			
			Cocaro.mainStage_mc.GoldDreamCity_btn.addEventListener(MouseEvent.CLICK, OtherFunction.GoldDreamCity_Click) ;
			Cocaro.mainStage_mc.LuckyCard_btn.addEventListener(MouseEvent.CLICK, LuckyCardFunction.LuckyCard_Click) ;
			Cocaro.mainStage_mc.DreamCity_btn.addEventListener(MouseEvent.CLICK, DreamCity_Click) ;
			Cocaro.mainStage_mc.Auction_btn.addEventListener(MouseEvent.CLICK, AuctionFunction.Auction_Click) ;
			Cocaro.mainStage_mc.Lottery_btn.addEventListener(MouseEvent.CLICK, LotteryFunction.Lottery_Click) ;
			Cocaro.mainStage_mc.Mail_btn.addEventListener(MouseEvent.CLICK, MailFunction.Mail_Click) ;
			//Cocaro.mainStage_mc.Group_btn.addEventListener(MouseEvent.CLICK, GroupFunction.Group_Click) ;
			Cocaro.mainStage_mc.Bank_btn.addEventListener(MouseEvent.CLICK, BankFunction.Bank_Click) ;
			//Cocaro.mainStage_mc.Shop_btn.addEventListener(MouseEvent.CLICK, ShopFunction.Shop_Click) ;
			//Cocaro.mainStage_mc.Football_btn.addEventListener(MouseEvent.CLICK, FootballFunction.Football_Click) ;
			//Cocaro.mainStage_mc.Help_btn.addEventListener(MouseEvent.CLICK, HelpFunction.Help_Click) ;
			//Cocaro.mainStage_mc.Quest_btn.addEventListener(MouseEvent.CLICK, QuestFunction.Quest_Click) ;
			Cocaro.mainStage_mc.Lock_btn.addEventListener(MouseEvent.CLICK, LockFunction.Lock_Click) ;
			Cocaro.mainStage_mc.Profile_btn.addEventListener(MouseEvent.CLICK, ProfileFunction.Profile_Click) ;	
			if (Cocaro.currPlayer.CountMsg > 0) {
				Cocaro.mainStage_mc.Mail_btn.CountMsg_txt.text = Cocaro.currPlayer.CountMsg ;
				Cocaro.mainStage_mc.Mail_btn.CountMsg_txt.visible = true ;
				Cocaro.mainStage_mc.Mail_btn.gotoAndStop(2) ;
			} else {
				Cocaro.mainStage_mc.Mail_btn.CountMsg_txt.visible = false ;
				Cocaro.mainStage_mc.Mail_btn.gotoAndStop(1) ;
			}
			//Cocaro.tf.appendText("==>2") ;
			ChatFunction.InitChat_OutTable() ;	
			InitChangeGame() ;
			Cocaro.mainStage_mc.Friend_mc.FriendGame_btn.addEventListener(MouseEvent.CLICK, FriendFunction.FriendGame_Click) ;
			Cocaro.mainStage_mc.Friend_mc.FriendZing_btn.addEventListener(MouseEvent.CLICK, FriendFunction.FriendZing_Click) ;
			Cocaro.mainStage_mc.Friend_mc.FriendTop_btn.addEventListener(MouseEvent.CLICK, FriendFunction.FriendTop_Click) ;
			Cocaro.mainStage_mc.Vaoban_Btn.addEventListener(MouseEvent.CLICK, Vaoban_Click) ;
			Cocaro.mainStage_mc.btnDG.addEventListener(MouseEvent.CLICK, btnDG_mc_Click) ;
			Cocaro.mainStage_mc.btnCT.addEventListener(MouseEvent.CLICK, btnCT_mc_Click) ;
			Cocaro.mainStage_mc.btnNew.addEventListener(MouseEvent.CLICK, btnNew_mc_Click) ;
			Cocaro.mainStage_mc.btnLQAG.addEventListener(MouseEvent.CLICK, btnLQAG_Click) ;
			Cocaro.mainStage_mc.btnNapAG.addEventListener(MouseEvent.CLICK, btnNapAG_mc_Click) ;
			Cocaro.mainStage_mc.btnDKGiaidau.addEventListener(MouseEvent.CLICK, btnDKGiaidau_Click) ;
			Cocaro.mainStage_mc.btnDKGiaidau.visible = false ;
			//Cocaro.tf.appendText("==>3") ;
			//}
			TopFunction.DisplayHotNew() ;
			LQAGFunction.Init() ;
			for (var i:int = 0; i < object.length; i++) 
			{
				Cocaro.levelID = object[i].Id ;
				var item:Object	 = object[i];
				var oLR : ObjectLevelRoom = new ObjectLevelRoom() ;
				if (item.Id == null) item.Id = 0;
				oLR.LevelID = item.Id ;
				oLR.LevelName = item.Name ;
				oLR.CurrPlayer = item.CurPlay ;
				oLR.MaxMark = item.MaxMark ;
				oLR.MinMark = item.MinMark ;
				Cocaro.currLevel = oLR ;
				break ;				
			}			
			ProcessOutTable_Frame2.movieRooms = new Array() ;	
			//{ Kiem tra gui yeu cau Feed len tuong
			var markChange : Number = 0 ;
			var markS : Number ;
			//if (markInit != 0) {
				//markChange = currPlayer.Mark - markInit ;
				//if (currPlayer.Mark > 1000000) {					
					//markS = 0.3 * markInit ;
				//} else if (currPlayer.Mark > 200000) {
					//markS = 0.5 * markInit;
				//} else if (currPlayer.Mark > 20000) {
					//markS = 2 * markInit  ;
				//} else {
					//markS = 2 * markInit  ;
				//}
				//if (markChange > markS) {
				//ExternalInterface.call("pushfeed",user.UserId);("Tiền lại về tay ta, Ha ha ha ... !")
				//} else {
					//if (currPlayer.Mark > 1000000)
						//markS = 0.3 * markInit ;
					//else 
						//markS = 0.5 * markInit;
					//if (markChange < 0 - markS)
				//ExternalInterface.call("pushfeed",user.UserId);("Tiền hết, tình tan, tư tưởng không tàn. Chơi tiếp!")
				//}
			//}
			//if (NonPlayMoney == InitMoney)
			//{
				//tf.appendText("ko play");
				Cocaro.Feed() ;
			//}
			//else if (PlayMoney - InitMoney > 0)
			//{	
				//tf.appendText("Play win");
				//ExternalInterface.call("pushfeed", user.UserId, 3 );
			//}
			//else if(PlayMoney - InitMoney < 0)
			//{
				//tf.appendText("Play lose");
				//ExternalInterface.call("pushfeed", user.UserId, 2 );
			//} 
			//}	
			//Cocaro.tf.appendText("==>3") ;
			if (Cocaro.currPlayer.Lock != 0) {
				LockFunction.FormUnLock() ;
			}
		}
		public static function clickLevel(_id:int, maxAG : int, minAG : int) : void { //Chon level vao thi dau
			if (_id == 0) return ;
			Cocaro.PlayMoney = 0;
			Cocaro.InitMoney = 0;
			Cocaro.NonPlayMoney = 0;
			Cocaro.SoundKick() ;
			/*if ((minAG == 0) && (currPlayer.Mark > 30000)) {
				showMSG("Bạn đã vượt quá cấp độ này!") ;
				return ;
			} else*/ if ((minAG == 10000) && (Cocaro.currPlayer.Mark < 10000)) {
				BasicFunction.ShowAlert("Bạn chưa đủ AG chơi cấp độ này!") ;
				return ;
			}
			var obj : Object = new Object() ;
			obj.evt = "2" ;
			obj.id = _id ;
			obj.gameid = Cocaro.GAME_ID ;
			Cocaro.mainSocket.sendService(JSON.encode(obj)) ;
    		//Remove Tang diem neu co
			var tmp :MovieClip = MovieClip(Cocaro.mainStage_mc.getChildByName("Thongbao")) ;
			while (tmp != null) {
				Cocaro.mainStage_mc.removeChild(tmp) ;
				var tmpHide:MovieClip = MovieClip(Cocaro.mainStage_mc.getChildByName("Hide"));
				while (tmpHide != null) {
					Cocaro.mainStage_mc.removeChild(tmpHide) ;
					tmpHide = MovieClip(Cocaro.mainStage_mc.getChildByName("Hide"));
				}
				tmp = MovieClip(Cocaro.mainStage_mc.getChildByName("Thongbao")) ;
			}
		}
		/******************************** Dang ky giai dau *****************************************/
		public static function RemovePopupDKGD() {
			var tmpRemove:MovieClip = MovieClip(Cocaro.mainStage_mc.getChildByName("Hide"));			
			while (tmpRemove != null) {
				Cocaro.mainStage_mc.removeChild(tmpRemove) ;
				tmpRemove = MovieClip(Cocaro.mainStage_mc.getChildByName("Hide"));
			}
			tmpRemove = MovieClip(Cocaro.mainStage_mc.getChildByName("DK_Giaidau"));
			while (tmpRemove != null) {
				Cocaro.mainStage_mc.removeChild(tmpRemove) ;
				tmpRemove = MovieClip(Cocaro.mainStage_mc.getChildByName("DK_Giaidau"));
			}
		}
		
		public static function btnHuybo_DKGD_click(evt : MouseEvent) {
			RemovePopupDKGD() ;
		}
		
		public static function btnXacnhan_DKGD_click(evt : MouseEvent) {
			RemovePopupDKGD() ;
			var objSend : Object = new Object() ;
			objSend.N = "talavuong" ;			
			var strTemp : String = "DK:" + JSON.encode(objSend);
			Cocaro.AGTransfer = 20000 ;
			Cocaro.mainSocket.sendData(strTemp);
		}
		
		public static function btnDKGiaidau_Click(evt : MouseEvent) {
			if (Cocaro.currPlayer.Mark < 20000) {
				BasicFunction.ShowAlert("Bạn không đủ tiền để tham gia giải đấu!") ;
				return ;
			}
			/*var tmpHide:MovieClip = MovieClip(new Hide());
			tmpHide.name = "Hide";
			tmpHide.x = 0 ;
			tmpHide.y = 0 ;
			tmpHide.alpha = 0 ;
			Cocaro.mainStage_mc.addChild(tmpHide) ;*/
			var tmpDK:MovieClip = MovieClip(new Popup_DKGiaidau());
			tmpDK.name = "DK_Giaidau";
			tmpDK.x = 0;
			tmpDK.y = 0;
			tmpDK.btnXacnhan.addEventListener(MouseEvent.CLICK, btnXacnhan_DKGD_click);
			tmpDK.Close_btn.addEventListener(MouseEvent.CLICK, btnHuybo_DKGD_click);
			Cocaro.mainStage_mc.addChild(tmpDK);
		}
		/*************************************** History Chuyen AG ******************************************/
		public static function DisplayHistory(str : String) : void {	
			var obj = JSON.decode(str) ;
			var _mc :MovieClip = MovieClip(new Player_TransferAG()) ;	
			_mc.txtFrom.text = obj.FromUser ;
			_mc.txtAG.text = BasicFunction.numberFormat(obj.AG, 0, false, true) ;
			_mc.txtTime.text = obj.WaitTime ;
			_mc.x = 0 ; 
			_mc.y = 5 + Cocaro.movieHistoryTF.length * 22 ;
			Cocaro.currPlayer.Mark = Cocaro.currPlayer.Mark + obj.AG ;
			if (Cocaro.mainStage_mc.currentFrame == 3) {
				var formatText : TextFormat = new TextFormat() ;				
				formatText.font = "Tahoma" ;
				formatText.bold = true ;
				formatText.size = 15 ; 
				Cocaro.mainStage_mc.Profile_mc.Mark_txt.text = "Hiện bạn có: " + BasicFunction.numberFormat(Cocaro.currPlayer.Mark, 0, false, true) + " AG";
				Cocaro.mainStage_mc.Profile_mc.Mark_txt.setTextFormat(formatText) ;
			}
			Cocaro.movieHistoryTF.push(_mc) ;			
			var pp : MovieClip = MovieClip(Cocaro.mainStage_mc.getChildByName("Popup_History")) ;
			if (pp == null) {
				/*var tmpHide:MovieClip = MovieClip(new Hide());
				tmpHide.name = "Hide";
				tmpHide.x = 0 ;
				tmpHide.y = 0 ;
				tmpHide.alpha = 0 ;
				Cocaro.mainStage_mc.addChild(tmpHide) ;*/
				pp = MovieClip(new Popup_Bank());
				pp.name = "Bank";
				pp.x = 0;
				pp.y = 0;				
				pp.close_btn.addEventListener(MouseEvent.CLICK, btnXacnhanHistory_mc_click);
				pp.History_btn.gotoAndStop(2) ;
				pp.TransferContent_mc.visible = false ;
				pp.LoanContent_mc.visible = false ;
				scrollHistoryTF_mc = new MovieClip() ;
				scrHistoryTF.source = scrollHistoryTF_mc;
				scrHistoryTF.setSize(400, 370); 
				scrHistoryTF.horizontalScrollPolicy = ScrollPolicy.OFF ;
				scrHistoryTF.verticalScrollPolicy = ScrollPolicy.ON ;
				scrHistoryTF.move( 30, 80);
				pp.addChild(scrHistoryTF) ;
				Cocaro.mainStage_mc.addChild(pp) ;
			}
			scrollHistoryTF_mc.addChild(_mc) ;
			scrHistoryTF.update() ;
		}
		
		public static function btnXacnhanHistory_mc_click(evt:MouseEvent) {
			Cocaro.SoundKick() ;
			var tmp :MovieClip = MovieClip(Cocaro.mainStage_mc.getChildByName("Bank")) ;
			Cocaro.mainStage_mc.removeChild(tmp) ;
			var tmpHide:MovieClip = MovieClip(Cocaro.mainStage_mc.getChildByName("Hide"));
			while (tmpHide != null) {
				Cocaro.mainStage_mc.removeChild(tmpHide) ;
				tmpHide = MovieClip(Cocaro.mainStage_mc.getChildByName("Hide"));
			}
		}
		public static function DreamCity_Click(evt : MouseEvent) {
			var url:String = "http://me.zing.vn/apps/dreamcity";
			var request:URLRequest = new URLRequest(url);
			navigateToURL(request, "_bank");		
		}
		public static function btnNapAG_mc_Click(evt : MouseEvent) {
			ExternalInterface.call("newwindow(100)");
		}
		public static function Error_Click(evt : MouseEvent) {
			var url:String = "http://me.zing.vn/b/athenagames2";
			var request:URLRequest = new URLRequest(url);
			navigateToURL(request, "_bank");			
		}
		
		public static function btnLQAG_Click(evt : MouseEvent) {
			Cocaro.mainStage_mc.btnLQAG.gotoAndStop(2) ;
			Cocaro.mainStage_mc.btnNew.gotoAndStop(1) ;
			Cocaro.mainStage_mc.btnDG.gotoAndStop(1) ;
			Cocaro.mainStage_mc.btnCT.gotoAndStop(1) ;
			Cocaro.mainStage_mc.New_mc.visible = false;
			Cocaro.mainStage_mc.CT_mc.visible = false ;
			Cocaro.mainStage_mc.DG_mc.visible = false ;
			Cocaro.mainStage_mc.LQAG_mc.visible = true ;
		}
		public static function btnNew_mc_Click(evt : MouseEvent) {
			Cocaro.mainStage_mc.btnNew.gotoAndStop(2) ;
			Cocaro.mainStage_mc.btnDG.gotoAndStop(1) ;
			Cocaro.mainStage_mc.btnCT.gotoAndStop(1) ;
			Cocaro.mainStage_mc.btnLQAG.gotoAndStop(1) ;
			Cocaro.mainStage_mc.New_mc.visible = true ;
			Cocaro.mainStage_mc.CT_mc.visible = false ;
			Cocaro.mainStage_mc.DG_mc.visible = false ;
			Cocaro.mainStage_mc.LQAG_mc.visible = false ;
			TopFunction.DisplayNew() ;
		}
		public static function btnDG_mc_Click(evt : MouseEvent) {
			Cocaro.mainStage_mc.btnNew.gotoAndStop(1) ;
			Cocaro.mainStage_mc.btnLQAG.gotoAndStop(1) ;
			Cocaro.mainStage_mc.btnDG.gotoAndStop(2) ;
			Cocaro.mainStage_mc.btnCT.gotoAndStop(1) ;
			Cocaro.mainStage_mc.New_mc.visible = false ;
			Cocaro.mainStage_mc.LQAG_mc.visible = false ;
			Cocaro.mainStage_mc.DG_mc.visible = true ;
			Cocaro.mainStage_mc.CT_mc.visible = false ;
			TopFunction.DisplayTopDG(TopFunction.arrDG) ;
		}
		public static function btnCT_mc_Click(evt : MouseEvent) {
			Cocaro.mainStage_mc.btnLQAG.gotoAndStop(1) ;
			Cocaro.mainStage_mc.btnNew.gotoAndStop(1) ;
			Cocaro.mainStage_mc.btnDG.gotoAndStop(1) ;
			Cocaro.mainStage_mc.btnCT.gotoAndStop(2) ;
			Cocaro.mainStage_mc.New_mc.visible = false;
			Cocaro.mainStage_mc.CT_mc.visible = true ;
			Cocaro.mainStage_mc.DG_mc.visible = false ;
			Cocaro.mainStage_mc.LQAG_mc.visible = false ;
			
			Cocaro.mainStage_mc.CT_mc.CTTuan_mc.visible = false ;
			Cocaro.mainStage_mc.CT_mc.CTThang_mc.visible = false ;
			Cocaro.mainStage_mc.CT_mc.CTTrongngay_mc.visible = false ;
			Cocaro.mainStage_mc.CT_mc.CTHomtruoc_mc.visible = true ;
			Cocaro.mainStage_mc.CT_mc.CTTrongngay_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.CT_mc.CTHomtruoc_btn.gotoAndStop(2) ;
			Cocaro.mainStage_mc.CT_mc.CTTuan_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.CT_mc.CTThang_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.CT_mc.CTTrongngay_btn.addEventListener(MouseEvent.CLICK, CTTrongngay_btn_Click) ;
			Cocaro.mainStage_mc.CT_mc.CTHomtruoc_btn.addEventListener(MouseEvent.CLICK, CTHomtruoc_btn_Click) ;
			Cocaro.mainStage_mc.CT_mc.CTTuan_btn.addEventListener(MouseEvent.CLICK, CTTuan_btn_Click) ;
			Cocaro.mainStage_mc.CT_mc.CTThang_btn.addEventListener(MouseEvent.CLICK, CTThang_btn_Click) ;
			TopFunction.DisplayTopCT_Homtruoc(TopFunction.arrCT_Homtruoc) ;
		}		
		public static function CTTrongngay_btn_Click(evt : MouseEvent) {
			Cocaro.mainStage_mc.CT_mc.CTTuan_mc.visible = false ;
			Cocaro.mainStage_mc.CT_mc.CTThang_mc.visible = false ;
			Cocaro.mainStage_mc.CT_mc.CTTrongngay_mc.visible = true ;
			Cocaro.mainStage_mc.CT_mc.CTHomtruoc_mc.visible = false ;
			Cocaro.mainStage_mc.CT_mc.CTTrongngay_btn.gotoAndStop(2) ;
			Cocaro.mainStage_mc.CT_mc.CTHomtruoc_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.CT_mc.CTTuan_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.CT_mc.CTThang_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.CT_mc.CTTrongngay_mc.Title_txt.text = "Top Cao thủ Ba cây trong ngày" ;
			TopFunction.DisplayTopCT_Trongngay(TopFunction.arrCT_Trongngay, 0) ;
		}		
		public static function CTHomtruoc_btn_Click(evt : MouseEvent) {
			Cocaro.mainStage_mc.CT_mc.CTTrongngay_mc.visible = false ;
			Cocaro.mainStage_mc.CT_mc.CTHomtruoc_mc.visible = true ;
			Cocaro.mainStage_mc.CT_mc.CTTuan_mc.visible = false ;
			Cocaro.mainStage_mc.CT_mc.CTThang_mc.visible = false ;
			Cocaro.mainStage_mc.CT_mc.CTTrongngay_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.CT_mc.CTHomtruoc_btn.gotoAndStop(2) ;
			Cocaro.mainStage_mc.CT_mc.CTTuan_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.CT_mc.CTThang_btn.gotoAndStop(1) ;
		}
		public static function CTTuan_btn_Click(evt : MouseEvent) {
			Cocaro.mainStage_mc.CT_mc.CTTuan_mc.visible = true ;
			Cocaro.mainStage_mc.CT_mc.CTThang_mc.visible = false ;
			Cocaro.mainStage_mc.CT_mc.CTTrongngay_mc.visible = false ;
			Cocaro.mainStage_mc.CT_mc.CTHomtruoc_mc.visible = false ;
			Cocaro.mainStage_mc.CT_mc.CTTrongngay_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.CT_mc.CTHomtruoc_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.CT_mc.CTTuan_btn.gotoAndStop(2) ;
			Cocaro.mainStage_mc.CT_mc.CTThang_btn.gotoAndStop(1) ;
			var dt:Date = new Date();
			var startDate :Date = new Date();
			var endDate :Date = new Date();
			if (dt.day == 0) {
				endDate.setDate(dt.getDate());
				startDate.setDate(endDate.getDate() - 6);
			} else if (dt.day == 1) {
				startDate.setDate(dt.getDate());
				endDate.setDate(startDate.getDate() + 6);				
			} else {
				startDate.setDate(dt.getDate() - dt.day + 1);
				endDate.setDate(startDate.getDate() + 6);
			}			
			var DateStart:String = (startDate.getDate()).toString();
			var MonStart:String = (startDate.getMonth() + 1).toString();			
			var DateEnd:String = (endDate.getDate()).toString();
			var MonEnd:String = (endDate.getMonth() + 1).toString();
			//tf.appendText("arrlength = " + arrCT_Tuan.length);
			//if ( arrCT_Tuan.length == 0)
				//Cocaro.mainStage_mc.CT_mc.CTTuan_mc.Title_txt.text = "Top Cao thủ Ba cây tuần từ " + DateStart + "/" + MonStart + " - " + DateEnd + "/" + MonEnd ; 
			//else
				//Cocaro.mainStage_mc.CT_mc.CTTuan_mc.Title_txt.text = TitleCaoThu;
			TopFunction.DisplayTopCT_Tuan(TopFunction.arrCT_Tuan) ;			
		}
		public static function CTThang_btn_Click(evt : MouseEvent) {
			Cocaro.mainStage_mc.CT_mc.CTThang_mc.visible = true ;
			Cocaro.mainStage_mc.CT_mc.CTTuan_mc.visible = false ;
			Cocaro.mainStage_mc.CT_mc.CTTrongngay_mc.visible = false ;
			Cocaro.mainStage_mc.CT_mc.CTHomtruoc_mc.visible = false ;
			Cocaro.mainStage_mc.CT_mc.CTTrongngay_mc.gotoAndStop(1) ;
			Cocaro.mainStage_mc.CT_mc.CTTrongngay_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.CT_mc.CTHomtruoc_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.CT_mc.CTTuan_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.CT_mc.CTThang_btn.gotoAndStop(2) ;
			var LastMonth: Date = new Date();
			var month = (LastMonth.getMonth() + 1).toString();
			Cocaro.mainStage_mc.CT_mc.CTThang_mc.Title_txt.text = "Top Cao thủ Ba cây tháng " + month;
			TopFunction.DisplayTopCT_Thang(TopFunction.arrCT_Thang) ;			
		}
		
		public static function Vaoban_Click(evt:MouseEvent) { 
			Cocaro.SoundKick() ;
			if (Cocaro.levelID == null) return ;
			if (Cocaro.levelID == 0) return ;
			var obj : Object = new Object() ;
			obj.evt = "2" ;
			obj.id = Cocaro.levelID ;
			obj.gameid = Cocaro.GAME_ID ;
			Cocaro.mainSocket.sendService(JSON.encode(obj)) ;
			//Cocaro.tf.appendText("==>SendLevel:" + JSON.encode(obj)) ;
    		Cocaro.htmlPrivateChat = Cocaro.mainStage_mc.Chat_mc.Private_txt.htmlText ;
			Cocaro.htmlWorldChat = Cocaro.mainStage_mc.Chat_mc.World_txt.htmlText ;
			Cocaro.htmlGameChat = Cocaro.mainStage_mc.Chat_mc.Game_txt.htmlText ;
			Cocaro.htmlAllChat = Cocaro.mainStage_mc.Chat_mc.All_txt.htmlText ;			
			//Remove Tang diem neu co
			var tmp :MovieClip = MovieClip(Cocaro.mainStage_mc.getChildByName("Thongbao")) ;
			while (tmp != null) {
				Cocaro.mainStage_mc.removeChild(tmp) ;
				var tmpHide:MovieClip = MovieClip(Cocaro.mainStage_mc.getChildByName("Hide"));
				while (tmpHide != null) {
					Cocaro.mainStage_mc.removeChild(tmpHide) ;
					tmpHide = MovieClip(Cocaro.mainStage_mc.getChildByName("Hide"));
				}
				tmp = MovieClip(Cocaro.mainStage_mc.getChildByName("Thongbao")) ;
			}
		}
		/**************************************** Qua Tang **************************************************/
		public static function QuaTang_fromServer(str: String): void {
			if (str == null) {
				Cocaro.mainStage_mc.Khung_Qua_mc.visible = false;
				return;
			}
			var objQT: Object = JSON.decode(str);		
			Cocaro.mainStage_mc.Khung_Qua_mc.visible = true;
			var numAG:String = objQT.PromMoney.toString();
			var numDay: String = objQT.DayPromotion.toString();
			Cocaro.currPlayer.Mark += int(numAG);
			Cocaro.mainStage_mc.Profile_mc.Mark_txt.text = BasicFunction.numberFormat(Cocaro.currPlayer.Mark, 0, false, true) + " AG";		
			var formatText : TextFormat = new TextFormat() ;				
			formatText.font = "Tahoma" ;
			formatText.bold = true ;
			formatText.size = 16 ;
			
			Cocaro.mainStage_mc.Profile_mc.Mark_txt.setTextFormat(formatText) ;	
				
			if (objQT.DayPromotion == 1)
			{
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay1_mc.gotoAndStop(2);
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay1_mc.Ngay_txt.text = numAG  + " AG";
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay2_mc.gotoAndStop(3);
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay2_mc.Ngay_txt.text = "200 AG";
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay3_mc.gotoAndStop(3);
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay3_mc.Ngay_txt.text = "300 AG";
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay4_mc.gotoAndStop(3);
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay4_mc.Ngay_txt.text = "400 AG";
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay5_mc.gotoAndStop(3);
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay5_mc.Ngay_txt.text = "500 AG";
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay6_mc.gotoAndStop(1);
			} else if (objQT.DayPromotion == 2)	{
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay1_mc.gotoAndStop(1);
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay2_mc.gotoAndStop(2);
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay2_mc.Ngay_txt.text = numAG +" AG";
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay3_mc.gotoAndStop(3);
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay3_mc.Ngay_txt.text = "300 AG";
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay4_mc.gotoAndStop(3);
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay4_mc.Ngay_txt.text = "400 AG";
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay5_mc.gotoAndStop(3);
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay5_mc.Ngay_txt.text = "500 AG";
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay6_mc.gotoAndStop(1);
			} else if (objQT.DayPromotion == 3) {
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay1_mc.gotoAndStop(1);
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay2_mc.gotoAndStop(1);
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay3_mc.gotoAndStop(2);
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay3_mc.Ngay_txt.text =  numAG + " AG";
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay4_mc.gotoAndStop(3);
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay4_mc.Ngay_txt.text = "400 AG";
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay5_mc.gotoAndStop(3);
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay5_mc.Ngay_txt.text = "500 AG";
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay6_mc.gotoAndStop(1);
			} else if (objQT.DayPromotion == 4)	{
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay1_mc.gotoAndStop(1);
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay2_mc.gotoAndStop(1);
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay3_mc.gotoAndStop(1);
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay4_mc.gotoAndStop(2);
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay4_mc.Ngay_txt.text = numAG + " AG";
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay5_mc.gotoAndStop(3);
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay5_mc.Ngay_txt.text = "500 AG";
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay6_mc.gotoAndStop(1);
			} else if (objQT.DayPromotion == 5)	{
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay1_mc.gotoAndStop(1);
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay2_mc.gotoAndStop(1);
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay3_mc.gotoAndStop(1);
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay4_mc.gotoAndStop(1);
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay5_mc.gotoAndStop(2);
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay5_mc.Ngay_txt.text = numAG + " AG";
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay6_mc.gotoAndStop(1);
			} else if (objQT.DayPromotion == 6)	{
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay1_mc.gotoAndStop(1);
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay2_mc.gotoAndStop(1);
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay3_mc.gotoAndStop(1);
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay4_mc.gotoAndStop(1);
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay5_mc.gotoAndStop(1);
				Cocaro.mainStage_mc.Khung_Qua_mc.btn_Ngay6_mc.gotoAndStop(1);
			}
			Cocaro.mainStage_mc.Khung_Qua_mc.Intro_mc.NumDay_txt.text = numAG + " AG";			
			Cocaro.mainStage_mc.Khung_Qua_mc.btn_NhanQua.addEventListener(MouseEvent.CLICK, btnNhanQua_click);			
		}
		// end khung qua tnag
		public static function btnNhanQua_click(evt : MouseEvent) {
			Cocaro.mainStage_mc.Khung_Qua_mc.visible = false;
			var tmpHide:MovieClip = MovieClip(Cocaro.mainStage_mc.getChildByName("Hide"));			
			while (tmpHide != null) {
				Cocaro.mainStage_mc.removeChild(tmpHide) ;
				tmpHide = MovieClip(Cocaro.mainStage_mc.getChildByName("Hide"));
			}
			//HCLink();
		}
	}
	
}